polozka menu vpravo

Otázka od: Tomas Bradle

31. 8. 2004 11:56

Zdravim vsechny,

v archivu konference jsem nasel, jak udelat polozku menu uplne vpravo,
vysledkem je naskedujici kod uvedeny na konci zpravy.

e:=GetLastError; mi vraci 1456 (A menu item was not found)

Nevite nekdo proc ? Co jsem zase prehlidnul ?

diky
Tomas Bradle
t.bradle@worldonline.cz


procedure TfrPMain.MakeRightRefresh;
var
  MenuItemInfo: TMenuItemInfo;
  Buffer: array[0..79] of Char;
  e: cardinal;
begin
ZeroMemory(@MenuItemInfo,SizeOf(MenuItemInfo));
with MenuItemInfo do
  begin
  cbSize:=44;
  fMask:=MIIM_TYPE;
  dwTypeData:=Buffer;
  cch:=SizeOf(Buffer);
  end;
if GetMenuItemInfo(mmAppMain.Handle, miRefresh.MenuIndex, True,
MenuItemInfo) then
  begin
  MenuItemInfo.fType:=MenuItemInfo.fType or MFT_RIGHTJUSTIFY;
  if SetMenuItemInfo(mmAppMain.Handle, miRefresh.MenuIndex, True,
MenuItemInfo)
    then DrawMenuBar(mmAppMain.WindowHandle);
  end
 else
  e:=GetLastError;
end;

definice menu:

object mmAppMain: TMainMenu
  Left = 48
  Top = 96
  object miPujcovnaMenu1: TMenuItem
    Caption = 'pujcovna'
    object miPSearch: TMenuItem
      Caption = 'pujcovani'
      ShortCut = 120
      OnClick = miPSearchClick
    end
    object miRezervace: TMenuItem
      Caption = 'rezervovat...'
      ShortCut = 117
      OnClick = miRezervaceClick
    end
    object N1: TMenuItem
      Caption = '-'
    end
    object miExitProg: TMenuItem
      Caption = 'ukoncit program'
      ShortCut = 32856
      OnClick = miExitProgClick
    end
  end
  .
  .
  .
  object miRefresh: TMenuItem
    Caption = 'obnovit'
    OnClick = miRefreshClick
  end